home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / demos / GL / demograph / demograph.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  3KB  |  140 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /* Enhancements:
  18. /*    Make [solid] option for 24bp display.
  19. /*    Make Single buffer RGB for 8bp P.I. (good for 3.3 dithering).
  20. /*    Coincide dates for multiple data files.
  21. */
  22. #include "stdio.h"
  23. #include "demograph.h"
  24.  
  25. #ifndef NULL
  26. #define NULL 0
  27. #endif
  28.  
  29. #define FPSFLAG "-f"
  30.  
  31. /* global variables */
  32. int x = 0;    /* input coordinates */
  33. int y = 0;
  34. int drawtype;    /* draw type -LINES, TOPS, SOLIDS, LIGHTED- see demograph.h */
  35. WINREC    winrec; /* record of window locations and flags */
  36. CATEGORY *categoryroot = NULL;    /* data category pointers */
  37. CATEGORY *curcategory = NULL;
  38. DATA *curdata;        /* states data */
  39. char *statesbuf = NULL;    /* map description - see states.c for details */
  40. MACHREC    machrec;    /* hardware options record */
  41.  
  42. /* error message for demograph usage */
  43. char usage[] = "usage: demograph [-s statesfile] filename [filename ...]\n";
  44.  
  45. /* flags for drawing action */
  46. int updatemap = FALSE;
  47. int updatetext = FALSE;
  48.  
  49. /* flag to wait for queue input */
  50. int qpause = TRUE;
  51.  
  52. void (*drawmap)(float *data);
  53. void displaydata(DATA *dataroot);
  54.  
  55. /* functions found here */
  56. FILE *openfile(char *filename, char *rw);
  57. void getmach(void);
  58.  
  59. main (int argc, char *argv[])
  60. {
  61.     long qdev;
  62.     short qval;
  63.     int i;
  64.  
  65.     void getstates(int argc, char *argv[]);
  66.     void getdata(int argc, char *argv[]);
  67.     void getmach(void);
  68.     void initwin(void);
  69.     void qprocess(int dev, short val);
  70.     
  71.     getstates(argc,argv);
  72.     getdata(argc,argv);
  73.  
  74.     getmach();
  75.  
  76.     winrec.fps = FALSE;
  77.     for (i = 1; i < argc; i++) {
  78.     if (strcmp(FPSFLAG,argv[i]) == 0) {
  79.         winrec.fps = TRUE;
  80.         break;
  81.     }
  82.     }
  83.  
  84.     initwin();
  85.  
  86.     while (TRUE) {
  87.     if (qpause) {
  88.         qdev = qread(&qval);
  89.         qprocess(qdev,qval);
  90.     } else {
  91.         if (qtest()) {
  92.         qdev = qread(&qval);
  93.         qprocess(qdev,qval);
  94.         }
  95.     }
  96.  
  97.     if (updatemap) {
  98.         (*drawmap)(curdata->data);
  99.     }
  100.     }
  101. }
  102.     
  103.  
  104. /* could do this using bits, but it might get confusing */
  105. void getmach()
  106. {
  107.     if (getgdesc(GD_BITS_NORM_ZBUFFER) == 0)
  108.     machrec.zbuffer = FALSE;
  109.     else
  110.     machrec.zbuffer = TRUE;
  111.  
  112.     if (getgdesc(GD_BITS_NORM_DBL_RED) == 0 || 
  113.         getgdesc(GD_BITS_NORM_DBL_BLUE) == 0 ||
  114.         getgdesc(GD_BITS_NORM_DBL_GREEN) == 0) {
  115.     machrec.RGB = FALSE;
  116.     } else {
  117.     machrec.RGB = TRUE;
  118.     }
  119. }
  120.  
  121.  
  122. /* OPENFILE opens a file for read */
  123. FILE *openfile(filename, rw)
  124. char *filename;
  125. char *rw;
  126. {
  127.     FILE *fileptr;
  128.  
  129.     if ((fileptr = fopen(filename,rw)) == NULL) {
  130.     fprintf(stderr,"cannot open file: %s\n",filename);
  131.     exit(1);
  132.     }
  133.     return(fileptr);
  134. }
  135.  
  136.  
  137. void displaydata(dataroot)
  138. DATA *dataroot;
  139. {}
  140.